package cc.owoo.godpen.reflect;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 * 泛型类型
 * Created by nimensei
 * 2022-05-31 下午 02:44
 */
public class GenericityType implements ParameterizedType {
    private final Class<?> rawType;
    private final Type[] actualTypeArguments;

    public GenericityType(Class<?> rawType, Class<?>... types) {
        if (rawType == null)
            throw new NullPointerException("原类型不能为空");
        if (types == null)
            throw new NullPointerException("泛型类型不能为空");
        for (var cls : types)
            if (cls == null)
                throw new NullPointerException("泛型类型不能为空");
        this.rawType = rawType;
        this.actualTypeArguments = types;
    }

    @Override
    public Type[] getActualTypeArguments() {
        return actualTypeArguments;
    }

    @Override
    public Type getRawType() {
        return rawType;
    }

    @Override
    public Type getOwnerType() {
        return null;
    }
}